package main;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class IntroFrame extends JFrame {

	private static final long serialVersionUID = 3159913170762735892L;

	JPanel border;
	JPanel main;
	JTextArea namePrompt;
	JTextField name;
	JButton submit_name;
	String submittedName;
	
	public IntroFrame() {
		this.setSize(250, 150);
		init();
		this.add(border);
		this.setVisible(true);
	}
	
	private void init() {
		border = new JPanel(new BorderLayout());
		main = new JPanel(new GridLayout(2, 1));
		border.add(main, BorderLayout.CENTER);
		submit_name = new JButton("Submit Name");
		namePrompt = new JTextArea("Welcome to Adventures of Adventure Land! \r\n           Please enter your name below");
		namePrompt.setEditable(false);
		name = new JTextField("Put name here");
		main.add(namePrompt);
		main.add(name); 
		border.add(submit_name, BorderLayout.SOUTH);
		submit_name.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent arg0) {
				CharCreation.name = name.getText();
				JOptionPane.showMessageDialog(main, "Welcome " + name.getText());
				Object[] possibilities = {"Wizard", "Warrior", "Thief", "Archer"};
				CharCreation.s = (String)JOptionPane.showInputDialog(
	                    main, 
	                    "Please choose your class. Keep in mind that \r\nthis will affect your journey through Adventure Land", "Choose your class",
	                    JOptionPane.PLAIN_MESSAGE,
	                    null,
	                    possibilities,
	                    "");
				try {
					CharCreation.createChar(CharCreation.s);
				} catch (Exception e) {
				}
				CharCreation.intro.dispose();
				// TODO: Launch Tutorial Frame
			}
		});
	}
}
